# 反注释掉Color VerbosePkgLists TotalDownload
sed -i 's/#Color/Color/g' /etc/pacman.conf
sed -i 's/#VerbosePkgLists/VerbosePkgLists/g' /etc/pacman.conf
sed -i 's/#TotalDownload/TotalDownload/g' /etc/pacman.conf

# 反注释掉[multilib]
sed -i 's/#\[multilib\]/\[multilib\]/g' /etc/pacman.conf
last_no=$(cat /etc/pacman.conf | grep -n "Include = /etc/pacman.d/mirrorlist" | sed -n '$p' | cut -d ':' -f 1)
sed -i "$last_no s/^#Include = \/etc\/pacman.d\/mirrorlist/Include = \/etc\/pacman.d\/mirrorlist/g" /etc/pacman.conf

# 添加非官方源archlinuxcn
if [ -z "$(cat /etc/pacman.conf | grep archlinuxcn)" ]; then
    echo -e "\n[archlinuxcn]" >>/etc/pacman.conf
    echo SigLevel = Optional TrustedOnly >>/etc/pacman.conf
    echo Server = https://mirrors.ustc.edu.cn/archlinuxcn/\$arch >>/etc/pacman.conf
fi

# 添加非官方源arch4edu
if [ -z "$(cat /etc/pacman.conf | grep arch4edu)" ]; then
    echo -e "\n[arch4edu]" >>/etc/pacman.conf
    echo SigLevel = Never >>/etc/pacman.conf
    echo Server = http://mirrors.tuna.tsinghua.edu.cn/arch4edu/\$arch >>/etc/pacman.conf
fi

pacman -Sy archlinuxcn-keyring
